package com.galeno.javabasic;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

/**
 * @author galeno
 * @Title:
 * @Description: 从Kafka中读取数据, 然后关联Mysql的维表, 最后将结果输出到MYSQL中
 * 如果使用DataStream API：KafkaSource -> Map 查询MySQL关联维表（MapState做缓存） -> JDBCSink 关联后的数据写入到MySQL
 * @date 2021/10/3020:34
 */
public class MysqlDimDemo2 {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port",9999);
        StreamExecutionEnvironment e = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);

        StreamTableEnvironment tE = StreamTableEnvironment.create(e);
        /**
         * 创建Source表
         */
        tE.executeSql("CREATE TABLE kafka_iteam" +
                "('user_id' INT," +
                "'item_id' INT," +
                "'category' INT," +
                "'action' STRING," +
                "'ts' TIMESTAMP(3) METADATA FROM 'timestamp'");


    }



}
